<?php
/**
 * Search View Helper
 */
class Zend_View_Helper_SearchForm extends Zend_View_Helper_Abstract
{
    protected $_country;
    protected $_city;
    protected $_star;
    protected $_em;
    protected $_repo;
    
    public function searchForm()
    {
        $this->_city=0;
        $this->_country=0;
        $this->_star=0;
        	 
        $this->_em = Zend_Registry::get('doctrine');
       	return $this;
    }
    
    public function setSearchCountry()
    {
        $this->_repo = $this->_em->getRepository('Entities\HaeBddCountry');
        $this->_country = $this->_repo->findAll();
       	return $this;
    }
    
    public function setSearchCity()
    {
        $this->_repo = $this->_em->getRepository('Entities\HaeBddCity');
        $this->_city = $this->_repo->findAll();
    	return $this;
    }
    
    public function setSearchStar()
    {
    	$this->_star=1;
    	return $this;
    }
    
    public function toString()
    {
        $registry= Zend_Registry::getInstance();
        
    	$xhtml ='<label>Location</label>';
    	if($this->_country!=1)
    	{
    	    $xhtml .='<select style="width:120px;" id="country_search" >';
    	    $xhtml .='<option value="0" >Choose Country</option>';
    		foreach ($this->_country as $country)
    		{
    			$xhtml .='<option value="'.$country->getId().'" >'.$country->getTitleEn().'</option>';
    		}
    		$xhtml .='</select>';
    	}
    	if($this->_city!=1)
    	{
    		$xhtml .='<select style="width:120px;margin-top:5px;margin-bottom:7px;" id="city_search" >';
    		$xhtml .='<option value="0" >Choose City</option>';
    		foreach ($this->_city as $city)
    		{
    			$xhtml .='<option value="'.$city->getId().'" >'.$city->getTitleEn().'</option>';
    		}
    		$xhtml .='</select>';
    	}
    	if($this->_star==1)
    	{
    	    $xhtml .='<label>Star</label>';
    		$xhtml .='<select style="width:120px" id="star_search" >';
    		$xhtml .='<option value="0" >Choose Star</option>';
    		$xhtml .='<option value="1" >1* - 2*</option>';
    		$xhtml .='<option value="2" >2* - 3*</option>';
    		$xhtml .='<option value="3" >3* - 4*</option>';
    		$xhtml .='<option value="4" >4* - 5*</option>';
    		$xhtml .='</select>';
    	}
    	return $xhtml;
    }
   	
    
}

?>